
/**
 * AJAX 载入用户修改密码页面
 *
 * @return 	void
 */
function bindUserPasswd() {
	$("#ajax-user-passwd-link").click(function(){
		$(".slider-item a").removeClass('selected-slider-item');
		$(this).addClass('selected-slider-item').blur();
		addMmLightBoxMsg('Wait a moment please, loading data ...', 0, 0, 1);
		$.get($(this).attr('href'), function(dt){
			$('#user-body-box').height('auto').html(dt);
			reactHeight();
			removeMmLightBoxMsg();
			$("#password-form").submit(function(){
				saveUserPassword($(this).attr('action'), $("#passwordold-input").val(), $("#passwordnew-input").val());
				return false;
			});
		});
		return false;
	});
}

/**
 * AJAX 保存用户修改密码
 *
 * @param 	string 		save_url 		POST提交保存新密码地址
 * @param 	string 		passwordold 	用户先用密码
 * @param 	string 		passwordnew 	用户新密码
 * @return 	boolean
 */
function saveUserPassword(save_url, passwordold, passwordnew) {
 	if(!passwordold || passwordold.length < 4 || passwordold.length > 20 || !passwordnew || passwordnew.length < 4 || passwordnew.length > 20) {
 		addMmLightBoxMsg('Sorry! You password length need in 4 to 20!', 1, 1);
 		return false;
 	}
 	addMmLightBoxMsg('Wait a moment please, save data ...', 0, 0, 1);
 	$("#password-submit").attr("disabled", true);
 	$.post(save_url, {'passwdold':passwordold, 'passwdnew':passwordnew},function(dt){
 		if(!dt.result){
 			addMmLightBoxMsg(dt.msg, 1, 1);
 		} else {
 			$("#password-form").get(0).reset();
 			addMmLightBoxMsg(dt.msg, 1);
 			window.setTimeout(function(){removeMmLightBoxMsg();}, 2000);
 		}
 		$("#password-submit").attr("disabled", false);
 	}, 'json');
 	return true;
}
